import { createApp } from 'vue'
import App from './App.vue'
import { setupAppPlugins } from '@/plugins'
import './assets/styles/global.scss'
import vue3TreeOrg from 'vue3-tree-org'
import 'vue3-tree-org/lib/vue3-tree-org.css'
import createBorderDirective from '@/utils/directive'
import print from 'vue3-print-nb'


const app = createApp(App)

// 注册插件、全局组件、方法
app.use(setupAppPlugins)
app.use(vue3TreeOrg)
 app.use(print)

app.directive('customColor', createBorderDirective())

// 添加全局方法
app.config.globalProperties.$yesNoBool = function (val) {
  return (val - 0) == 1 ? '是' : (val - 0) == 2 ? '否' : '否'
};

app.config.globalProperties.$dictToVal = (dictList, val) => {
  for (let i = 0; i < dictList.length; i++) {
    if (val == dictList[i].id) {
      return dictList[i].name
    }
  }
}
window.myYears = {
    currentYear:new Date().getFullYear(),
    lastYear:new Date().getFullYear() - 1
  }

app.mount('#app')

//设置用户名
function setUserName(name) {
  $('.user-name').html(name);
}
